package com.libs.sys.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.libs.sys.mapper.SeatMapper;
import com.libs.sys.model.Seat;
import com.libs.sys.service.SeatService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * InnoDB free: 10240 kB 服务实现类
 * </p>
 *
 * @author SR.Y
 * @since 2021-08-11
 */
@Service
public class SeatServiceImpl extends ServiceImpl<SeatMapper, Seat> implements SeatService {

    @Override
    public boolean add(Seat seat) {
        return save(seat);
    }

    @Override
    public Seat selectoneseat(String id) {
        return getById(id);
    }



    @Override
    public Page<Seat> selectallseat(Integer pageSize, Integer pageNum) {
        Page<Seat> page = new Page<>(pageSize,pageNum);
        return page(page);
    }

    @Override
    public Seat getseatBySeatId(String seatid) {
        Page<Seat> page = new Page<>(0, 1);
        QueryWrapper<Seat> wrapper = new QueryWrapper<>();
        LambdaQueryWrapper<Seat> lambda = wrapper.lambda();
        if(StrUtil.isNotEmpty(seatid)){
            lambda.eq(Seat::getSeatid,seatid);
        }
        return page(page,wrapper).getRecords().get(0);
    }

}
